﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BullTasDesaDal.Entities;
using NHibernate.Criterion;
using NHibernate.SqlCommand;

namespace BullTasDesaDal.Service
{
    public class RegionService
    {
        public static IList<Region> GetAll()
        {
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                return session.CreateCriteria(typeof(Region))
                    .List<Region>();


            }
        }

        public static IList<Zone> GetZoneByRegion(string idRegion)
        {
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                return session.CreateCriteria(typeof(Zone))
                    .CreateAlias("Region", "zRegion", JoinType.InnerJoin)
                    .Add(Restrictions.Eq("zRegion.Id", idRegion))
                    .List<Zone>();


            }
        }
    }
}